package com.crm.controller;

import com.crm.base.PageResult;
import com.crm.base.ResponseResult;
import com.crm.domain.dto.BusinessDto;
import com.crm.domain.vo.BusinessVo;
import com.crm.service.PublicPoolService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Api(tags = "公海池")
@RestController
@RequiredArgsConstructor
@RequestMapping("/business")
public class PublicPoolController {

    private final PublicPoolService publicPoolService;

    /**
     * 分页查询公海池列表
     *
     * @param businessDto
     * @return
     */
    @ApiModelProperty(value = "公海池列表")
    @GetMapping("/pool")
    public PageResult<List<BusinessVo>> page(BusinessDto businessDto) {
        PageResult<BusinessVo> pageResult = publicPoolService.queryAll(businessDto);
        return PageResult.success(pageResult.getMsg(), pageResult.getRows(), pageResult.getTotal());
    }


    /**
     * 踢回公海池
     * @param id
     * @param reasonId
     * @return
     */
    @ApiModelProperty(value = "踢回公海池")
    @PutMapping("/back/{id}/{resonId}")
    public ResponseResult backPool(
            @PathVariable("id") Long id,
            @PathVariable("resonId") Long reasonId) {
        return publicPoolService.backPool(id, reasonId);
    }
}
